home *** CD-ROM | disk | FTP | other *** search
- ;ASL Multi-select file requester subroutine
-
- ;Original ASL File Requester code by Paul Burkey
- ;Multi-selection added by Curt Esser
-
- ;last modified Aug 21 1999
-
- ;it remembers the last user-set size & position
- ;for future calls
-
- ;Sorry - too much stuff would need to be "shared"
- ;to make this practical in a Function
-
- ;it also works with the ReqTools patch installed
- ;but the size & position settings are ignored
-
- ;NOTE: you MUST use the ORIGINAL amigalibs.res file
- ;there is something wrong with the version that comes with
- ;Freds NCS - it doesn't return the correct fr_NumArgs
-
- WBStartup
- WBenchToFront_
- FindScreen 0
- *scr.Screen=Peek.l(Addr Screen(0))
-
- ;setup some defaults for the AslFilerequester
-
- percentx.q = .36 ;% of screen width to use
- percenty.q = .65 ;% of screen height to use
- domulti.w = 1 ;0 for no multi-selection
- title$ = "ASL multi TEST" ;requester title text
- doit$ = "Load" ;text for OK gadget
- filename$ = "" ;initial default file
- pathname$ = "RAM:" ;initial default path
-
- rqwidth.w = *scr\Width * percentx ;calculate initial width
- rqheight.w = *scr\Height* percenty ;calculate initial height
- rqleft.w = *scr\Width/2 - rqwidth/2 ;calculate initial x position
- rqtop.w = *scr\Height/2- rqheight/2 ;calculate initial y position
-
-
- NEWTYPE.files ;for the selections list
- pathname.s
- End NEWTYPE
-
- Dim List Selections.files(500) ;or more if you need to...
- ;if more than the dimensioned
- ;amount of files are selected
- ;the excess selected files
- ;will simply be ignored
-
- ;=====================================================================
-
- ;the demo loop
-
- Repeat
- ClearList Selections()
- Gosub filerequest
- NPrint " "
- NPrint "Selected ",selected.l ;selected = number of files
- ResetList Selections()
- While NextItem(Selections()) ;each item in the list
- NPrint Selections()\pathname ;is a string with the full
- ;pathname of a selected file
- Wend
- Until f$="" OR ok.l=0 ;requester was cancelled or failed to open
-
- End
-
-
- ;=====================================================================
-
-
- filerequest
-
- Dim Tags.TagItem(11)
- Tags(0)\ti_Tag =#ASLFR_Screen,*scr
- Tags(1)\ti_Tag =#ASLFR_PositiveText,&doit$
- Tags(2)\ti_Tag =#ASLFR_RejectIcons,-1
- Tags(3)\ti_Tag =#ASLFR_TitleText,&title$
- Tags(4)\ti_Tag =#ASLFR_InitialFile,&filename$
- Tags(5)\ti_Tag =#ASLFR_InitialDrawer,&pathname$
- Tags(6)\ti_Tag =#ASLFR_InitialLeftEdge,rqleft
- Tags(7)\ti_Tag =#ASLFR_InitialTopEdge,rqtop
- Tags(8)\ti_Tag =#ASLFR_InitialWidth,rqwidth
- Tags(9)\ti_Tag =#ASLFR_InitialHeight,rqheight
- Tags(10)\ti_Tag=#ASLFR_DoMultiSelect,domulti
- Tags(11)\ti_Tag=#TAG_END,0
-
- *filereq.FileRequester=AllocAslRequest_(#ASL_FileRequest,&Tags(0))
- If *filereq
- ok.l=AslRequest_(*filereq,&Tags(0))
- If ok
- f$=Peek.s(*filereq\fr_Drawer)
- If f$<>""
- If Right$(f$,1)<>":" AND Right$(f$,1)<>"/" Then f$=f$+"/"
- EndIf
- pathname$=f$ ;the full path
-
- filename$=Peek.s(*filereq\fr_File);the file name
-
- selected.l= *filereq\fr_NumArgs ;number of files selected
-
- If selected>1 ;multiple files were selected
-
- For i = 0 To selected -1
- *nextarg.l=Peek.l(*filereq\fr_ArgList+(8*i)+4)
- If AddItem(Selections())
- Selections()\pathname=pathname$+Peek.s(*nextarg)
- EndIf
- Next
-
- Else ;one or less selected
-
- If AddItem(Selections())
- Selections()\pathname=pathname$+filename$
- EndIf
-
- EndIf
-
- rqwidth =*filereq\fr_Width ;save the user set positions
- rqheight=*filereq\fr_Height ;and sizes for next time
- rqleft =*filereq\fr_LeftEdge
- rqtop =*filereq\fr_TopEdge
-
- EndIf
-
- FreeAslRequest_(*filereq) ;don't forget to free it!
-
- EndIf
-
- Return
-